package com.link.base.base.mpconfig.service;


import com.link.base.base.coupons.model.Coupons;
import com.link.base.base.mpconfig.dao.mybatis.mapper.HomePopUpMapper;
import com.link.base.base.mpconfig.model.HomePopUp;
import com.link.core.basic.dao.mapper.BasicMapper;
import com.link.core.basic.service.BasicServiceImpl;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * 小程序首页弹框配置
 *
 * @author: 闫有霞
 * @date: 2019/12/19
 */

@Service
public class HomePopUpServiceImpl extends BasicServiceImpl<HomePopUp> implements HomePopUpService {

    @Resource
    private HomePopUpMapper homePopUpMapper;
    
    @Override
    public BasicMapper<HomePopUp> getBasicMapper() {
        return homePopUpMapper;
    }

    /**
     * <p>根据appId查询</p>
     * @author yanyouxia
     * @param homePopUp
     */
    @Override
    public List<HomePopUp> queryByAppId(HomePopUp homePopUp) throws Exception {
        List<HomePopUp> homePopUpList;
        homePopUpList = homePopUpMapper.queryByAppId(homePopUp);
        return homePopUpList;
    }

    /**
     * <p>根据客户ID accntId 以及 活动 ID salAccntId 判断
     *    该客户是否参加过该活动  参加过返回活动 ID
     *    及客户ID</p>
     * @author yanyouxia
     * @param homePopUp
     */
    @Override
    public List<HomePopUp> checkAccntActivity(HomePopUp homePopUp) throws Exception {
        List<HomePopUp>  acctActivityList;
        acctActivityList = homePopUpMapper.checkAccntActivity(homePopUp);
        return acctActivityList;
    }


    /**
     * <p>根据linkId查询 优惠券</p>
     * @author yanyouxia
     * @param homePopUp
     */

    @Override
    public List<Coupons> getActivityCoupon(HomePopUp homePopUp) throws Exception {
        List<Coupons> couponList;
        couponList = homePopUpMapper.getActivityCoupon(homePopUp);
        return couponList;
    }

    /**
     * <p>根据客户ID accntId 以及 活动 ID salAccntId 判断
     *     该客户是否领取过该活动下的卡券  领取过返回卡券ID
     *     及客户ID</p>
     * @author yanyouxia
     * @param homePopUp
     */

    @Override
    public List<HomePopUp> checkAccntCoupon(HomePopUp homePopUp) throws Exception {
        List<HomePopUp>  acctCouponList;
        acctCouponList = homePopUpMapper.checkAccntCoupon(homePopUp);
        return acctCouponList;
    }
    /**
     * <p>根据客户ID accntId 以及 活动 ID linkId 判断
     *     该客户的会员ID是否领取过该会员卡  领取过返回会员卡ID
     *     及客户ID</p>
     * @author yanyouxia
     * @param homePopUp
     */

    @Override
    public List<HomePopUp> checkAccntMember(HomePopUp homePopUp) throws Exception {
        List<HomePopUp>  acctMemberList;
        acctMemberList = homePopUpMapper.checkAccntMember(homePopUp);
        return acctMemberList;
    }

    /**
     * <p>根据accntId查询 最新的待通知的优惠券</p>
     * @author yanyouxia
     * @param homePopUp
     */

    @Override
    public List<Coupons> getAccntCoupon(HomePopUp homePopUp) throws Exception {
        List<Coupons> noticeCoupList;
        noticeCoupList = homePopUpMapper.getAccntCoupon(homePopUp);
        return noticeCoupList;
    }

    /**
     *@createdBy 闫有霞
     *@date 2018/12/1
     *@methods: updateStatus
     *@param: homePopUp
     *@return: void
     *@description: 更新弹框状态是否有效
     **/
    @Override
    public void updateStatus(HomePopUp homePopUp) throws Exception {
        homePopUpMapper.updateStatus(homePopUp);
    }


}

